<!DOCTYPE html>
<html lang="en">
  <head>
    <title>CoroutineScheduler Protocol Reference</title>
    <link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
    <link rel="stylesheet" type="text/css" href="../css/highlight.css" />
    <meta charset='utf-8'>
    <script src="../js/jquery.min.js" defer></script>
    <script src="../js/jazzy.js" defer></script>
    
    <script src="../js/lunr.min.js" defer></script>
    <script src="../js/typeahead.jquery.js" defer></script>
    <script src="../js/jazzy.search.js" defer></script>
  </head>
  <body>
    <a name="//apple_ref/swift/Protocol/CoroutineScheduler" class="dashAnchor"></a>
    <a title="CoroutineScheduler Protocol Reference"></a>
    <header>
      <div class="content-wrapper">
        <p><a href="../index.html">SwiftCoroutine 2.1.9 Docs</a> (88% documented)</p>
        <p class="header-right">
          <form role="search" action="../search.json">
            <input type="text" placeholder="Search documentation" data-typeahead>
          </form>
        </p>
      </div>
    </header>
    <div class="content-wrapper">
      <p id="breadcrumbs">
        <a href="../index.html">SwiftCoroutine Reference</a>
        <img id="carat" src="../img/carat.png" />
        CoroutineScheduler Protocol Reference
      </p>
    </div>
    <div class="content-wrapper">
      <nav class="sidebar">
        <ul class="nav-groups">
          <li class="nav-group-name">
            <a href="../Classes.html">Classes</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Classes/CoChannel.html">CoChannel</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/CoChannel/BufferType.html">– BufferType</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/CoChannel/Receiver.html">– Receiver</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/CoChannel/Sender.html">– Sender</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/CoFuture.html">CoFuture</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/CoPromise.html">CoPromise</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/CoScope.html">CoScope</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="../Enums.html">Enumerations</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Enums/CoChannelError.html">CoChannelError</a>
              </li>
              <li class="nav-group-task">
                <a href="../Enums/CoFutureError.html">CoFutureError</a>
              </li>
              <li class="nav-group-task">
                <a href="../Enums/CoroutineError.html">CoroutineError</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="../Extensions.html">Extensions</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Extensions/DispatchQueue.html">DispatchQueue</a>
              </li>
              <li class="nav-group-task">
                <a href="../Extensions/Publisher.html">Publisher</a>
              </li>
              <li class="nav-group-task">
                <a href="../Extensions/URLSession.html">URLSession</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="../Protocols.html">Protocols</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Protocols/CoCancellable.html">CoCancellable</a>
              </li>
              <li class="nav-group-task">
                <a href="../Protocols/CoroutineScheduler.html">CoroutineScheduler</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="../Structs.html">Structures</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Structs/Coroutine.html">Coroutine</a>
              </li>
            </ul>
          </li>
        </ul>
      </nav>
      <article class="main-content">
        <section>
          <section class="section">
            <h1>CoroutineScheduler</h1>
              <div class="declaration">
                <div class="language">
                  
                  <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">CoroutineScheduler</span></code></pre>

                </div>
              </div>
            <p>A protocol that defines how to execute a task.</p>

<p>This protocol has extension methods that allow to launch coroutines on a current scheduler.
Inside the coroutine you can use such methods as <code><a href="../Structs/Coroutine.html#/s:14SwiftCoroutine0B0V5awaityyyyycXEKFZ">Coroutine.await(_:)</a></code>, <code><a href="../Classes/CoFuture.html#/s:14SwiftCoroutine8CoFutureC5awaitxyKF">CoFuture.await()</a></code>,
and <code><a href="../Protocols/CoroutineScheduler.html#/s:14SwiftCoroutine0B9SchedulerPAAE5awaityqd__qd__yKXEKlF">CoroutineScheduler.await(_:)</a></code> to suspend the coroutine without blocking a thread
and resume it when the result is ready.</p>

<p>To launch a coroutine, use <code>CoroutineScheduler.startCoroutine(_:)</code>.</p>
<pre class="highlight swift"><code><span class="c1">//execute coroutine on the main thread</span>
<span class="kt">DispatchQueue</span><span class="o">.</span><span class="n">main</span><span class="o">.</span><span class="n">startCoroutine</span> <span class="p">{</span>

    <span class="c1">//extension that returns CoFuture&lt;(data: Data, response: URLResponse)&gt;</span>
    <span class="k">let</span> <span class="nv">dataFuture</span> <span class="o">=</span> <span class="kt">URLSession</span><span class="o">.</span><span class="n">shared</span><span class="o">.</span><span class="nf">dataTaskFuture</span><span class="p">(</span><span class="nv">for</span><span class="p">:</span> <span class="n">url</span><span class="p">)</span>

    <span class="c1">//await result that suspends coroutine and doesn't block the thread</span>
    <span class="k">let</span> <span class="nv">data</span> <span class="o">=</span> <span class="k">try</span> <span class="n">dataFuture</span><span class="o">.</span><span class="nf">await</span><span class="p">()</span><span class="o">.</span><span class="n">data</span>

<span class="p">}</span>
</code></pre>

<p>The framework includes the implementation of this protocol for <code>DispatchQueue</code>
and you can easily make the same for other schedulers as well.</p>
<pre class="highlight swift"><code><span class="kd">extension</span> <span class="kt">OperationQueue</span><span class="p">:</span> <span class="kt">CoroutineScheduler</span> <span class="p">{</span>

    <span class="kd">public</span> <span class="kd">func</span> <span class="nf">scheduleTask</span><span class="p">(</span><span class="n">_</span> <span class="nv">task</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">Void</span><span class="p">)</span> <span class="p">{</span>
        <span class="nf">addOperation</span><span class="p">(</span><span class="n">task</span><span class="p">)</span>
    <span class="p">}</span>

<span class="p">}</span>
</code></pre>

          </section>
          <section class="section task-group-section">
            <div class="task-group">
              <ul>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:14SwiftCoroutine0B9SchedulerP12scheduleTaskyyyycF"></a>
                    <a name="//apple_ref/swift/Method/scheduleTask(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:14SwiftCoroutine0B9SchedulerP12scheduleTaskyyyycF">scheduleTask(_:<wbr>)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Performs the task at the next possible opportunity.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">func</span> <span class="nf">scheduleTask</span><span class="p">(</span><span class="n">_</span> <span class="nv">task</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">Void</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:14SwiftCoroutine0B9SchedulerPAAE05startB02in4taskyAA7CoScopeCSg_yyKctF"></a>
                    <a name="//apple_ref/swift/Method/startCoroutine(in:task:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:14SwiftCoroutine0B9SchedulerPAAE05startB02in4taskyAA7CoScopeCSg_yyKctF">startCoroutine(in:<wbr>task:<wbr>)</a>
                    </code>
                      <span class="declaration-note">
                        Extension method
                      </span>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Start a new coroutine on the current scheduler.</p>

<p>As an example, with <code><a href="../Structs/Coroutine.html#/s:14SwiftCoroutine0B0V5awaityyyyycXEKFZ">Coroutine.await(_:)</a></code> you can wrap asynchronous functions with callbacks
to synchronously receive its result without blocking the thread.</p>
<pre class="highlight swift"><code><span class="c1">//start new coroutine on the main thread</span>
<span class="kt">DispatchQueue</span><span class="o">.</span><span class="n">main</span><span class="o">.</span><span class="n">startCoroutine</span> <span class="p">{</span>
    <span class="c1">//execute someAsyncFunc() and await result from its callback</span>
    <span class="k">let</span> <span class="nv">result</span> <span class="o">=</span> <span class="k">try</span> <span class="kt">Coroutine</span><span class="o">.</span><span class="n">await</span> <span class="p">{</span> <span class="nf">someAsyncFunc</span><span class="p">(</span><span class="nv">callback</span><span class="p">:</span> <span class="nv">$0</span><span class="p">)</span> <span class="p">}</span>
<span class="p">}</span>
</code></pre>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">startCoroutine</span><span class="p">(</span><span class="k">in</span> <span class="nv">scope</span><span class="p">:</span> <span class="kt"><a href="../Classes/CoScope.html">CoScope</a></span><span class="p">?</span> <span class="o">=</span> <span class="kc">nil</span><span class="p">,</span> <span class="nv">task</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">()</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt">Void</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>scope</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p><code><a href="../Classes/CoScope.html">CoScope</a></code>to add coroutine to.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>task</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The closure that will be executed inside coroutine. If the task throws an error, then the coroutine will be terminated.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:14SwiftCoroutine0B9SchedulerPAAE5awaityqd__qd__yKXEKlF"></a>
                    <a name="//apple_ref/swift/Method/await(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:14SwiftCoroutine0B9SchedulerPAAE5awaityqd__qd__yKXEKlF">await(_:<wbr>)</a>
                    </code>
                      <span class="declaration-note">
                        Extension method
                      </span>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Start a coroutine and await its result. Must be called inside other coroutine.</p>

<p>This method allows to execute given task on other scheduler and await its result without blocking the thread.</p>
<pre class="highlight swift"><code><span class="c1">//start coroutine on the main thread</span>
<span class="kt">DispatchQueue</span><span class="o">.</span><span class="n">main</span><span class="o">.</span><span class="n">startCoroutine</span> <span class="p">{</span>
    <span class="c1">//execute someSyncFunc() on global queue and await its result</span>
    <span class="k">let</span> <span class="nv">result</span> <span class="o">=</span> <span class="k">try</span> <span class="kt">DispatchQueue</span><span class="o">.</span><span class="nf">global</span><span class="p">()</span><span class="o">.</span><span class="n">await</span> <span class="p">{</span> <span class="nf">someSyncFunc</span><span class="p">()</span> <span class="p">}</span>
<span class="p">}</span>
</code></pre>
<div class="aside aside-throws">
    <p class="aside-title">Throws</p>
    Rethrows an error from the task or throws <code><a href="../Enums/CoroutineError.html">CoroutineError</a></code>.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">@inlinable</span>
<span class="kd">public</span> <span class="kd">func</span> <span class="n">await</span><span class="o">&lt;</span><span class="kt">T</span><span class="o">&gt;</span><span class="p">(</span><span class="n">_</span> <span class="nv">task</span><span class="p">:</span> <span class="p">()</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt">T</span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt">T</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>task</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The closure that will be executed inside coroutine.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>Returns the result of the task.</p>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:14SwiftCoroutine0B9SchedulerPAAE15coroutineFutureyAA02CoE0Cyqd__Gqd__yKclF"></a>
                    <a name="//apple_ref/swift/Method/coroutineFuture(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:14SwiftCoroutine0B9SchedulerPAAE15coroutineFutureyAA02CoE0Cyqd__Gqd__yKclF">coroutineFuture(_:<wbr>)</a>
                    </code>
                      <span class="declaration-note">
                        Extension method
                      </span>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Starts a new coroutine and returns its future result.</p>

<p>This method allows to execute a given task asynchronously inside a coroutine
and returns <code><a href="../Classes/CoFuture.html">CoFuture</a></code> with its future result immediately.</p>
<div class="aside aside-note">
    <p class="aside-title">Note</p>
    If you cancel this <code><a href="../Classes/CoFuture.html">CoFuture</a></code>, it will also cancel the coroutine that was started inside of it.

</div>
<pre class="highlight swift"><code><span class="c1">//execute someSyncFunc() on global queue and return its future result</span>
<span class="k">let</span> <span class="nv">future</span> <span class="o">=</span> <span class="kt">DispatchQueue</span><span class="o">.</span><span class="nf">global</span><span class="p">()</span><span class="o">.</span><span class="n">coroutineFuture</span> <span class="p">{</span> <span class="nf">someSyncFunc</span><span class="p">()</span> <span class="p">}</span>
<span class="c1">//start coroutine on main thread</span>
<span class="kt">DispatchQueue</span><span class="o">.</span><span class="n">main</span><span class="o">.</span><span class="n">startCoroutine</span> <span class="p">{</span>
    <span class="c1">//await result of future</span>
    <span class="k">let</span> <span class="nv">result</span> <span class="o">=</span> <span class="k">try</span> <span class="n">future</span><span class="o">.</span><span class="nf">await</span><span class="p">()</span>
<span class="p">}</span>
</code></pre>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">@inlinable</span>
<span class="kd">public</span> <span class="kd">func</span> <span class="n">coroutineFuture</span><span class="o">&lt;</span><span class="kt">T</span><span class="o">&gt;</span><span class="p">(</span><span class="n">_</span> <span class="nv">task</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">()</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt">T</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt"><a href="../Classes/CoFuture.html">CoFuture</a></span><span class="o">&lt;</span><span class="kt">T</span><span class="o">&gt;</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>task</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The closure that will be executed inside the coroutine.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>Returns <code><a href="../Classes/CoFuture.html">CoFuture</a></code> with the future result of the task.</p>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:14SwiftCoroutine0B9SchedulerPAAE5actor2of10bufferType4bodyAA9CoChannelC6SenderCyqd___Gqd__m_AI06BufferG0Oyqd___GyAI8ReceiverCyqd___GKctlF"></a>
                    <a name="//apple_ref/swift/Method/actor(of:bufferType:body:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:14SwiftCoroutine0B9SchedulerPAAE5actor2of10bufferType4bodyAA9CoChannelC6SenderCyqd___Gqd__m_AI06BufferG0Oyqd___GyAI8ReceiverCyqd___GKctlF">actor(of:<wbr>bufferType:<wbr>body:<wbr>)</a>
                    </code>
                      <span class="declaration-note">
                        Extension method
                      </span>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Starts new coroutine that is receiving messages from its mailbox channel and returns its mailbox channel as a <code>Sender</code>.</p>

<p>An actor coroutine builder conveniently combines a coroutine,
the state that is confined and encapsulated into this coroutine,
and a channel to communicate with other coroutines.</p>
<div class="aside aside-note">
    <p class="aside-title">Note</p>
    If you cancel this <code><a href="../Classes/CoChannel.html">CoChannel</a></code>, it will also cancel the coroutine that was started inside of it.

</div>
<pre class="highlight swift"><code><span class="c1">//Message types for actor</span>
<span class="kd">enum</span> <span class="kt">CounterMessages</span> <span class="p">{</span>
    <span class="k">case</span> <span class="n">increment</span><span class="p">,</span> <span class="nf">getCounter</span><span class="p">(</span><span class="kt">CoPromise</span><span class="o">&lt;</span><span class="kt">Int</span><span class="o">&gt;</span><span class="p">)</span>
<span class="p">}</span>

<span class="k">let</span> <span class="nv">actor</span> <span class="o">=</span> <span class="kt">DispatchQueue</span><span class="o">.</span><span class="nf">global</span><span class="p">()</span><span class="o">.</span><span class="nf">actor</span><span class="p">(</span><span class="nv">of</span><span class="p">:</span> <span class="kt">CounterMessages</span><span class="o">.</span><span class="k">self</span><span class="p">)</span> <span class="p">{</span> <span class="n">receiver</span> <span class="k">in</span>
    <span class="k">var</span> <span class="nv">counter</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="k">for</span> <span class="n">message</span> <span class="k">in</span> <span class="n">receiver</span> <span class="p">{</span>
        <span class="k">switch</span> <span class="n">message</span> <span class="p">{</span>
        <span class="k">case</span> <span class="o">.</span><span class="nv">increment</span><span class="p">:</span>
            <span class="n">counter</span> <span class="o">+=</span> <span class="mi">1</span>
        <span class="k">case</span> <span class="o">.</span><span class="nf">getCounter</span><span class="p">(</span><span class="k">let</span> <span class="nv">promise</span><span class="p">):</span>
            <span class="n">promise</span><span class="o">.</span><span class="nf">success</span><span class="p">(</span><span class="n">counter</span><span class="p">)</span>
        <span class="p">}</span>
    <span class="p">}</span>
<span class="p">}</span>

<span class="kt">DispatchQueue</span><span class="o">.</span><span class="nf">concurrentPerform</span><span class="p">(</span><span class="nv">iterations</span><span class="p">:</span> <span class="mi">100_000</span><span class="p">)</span> <span class="p">{</span> <span class="n">_</span> <span class="k">in</span>
    <span class="n">actor</span><span class="o">.</span><span class="nf">offer</span><span class="p">(</span><span class="o">.</span><span class="n">increment</span><span class="p">)</span>
<span class="p">}</span>

<span class="k">let</span> <span class="nv">promise</span> <span class="o">=</span> <span class="kt">CoPromise</span><span class="o">&lt;</span><span class="kt">Int</span><span class="o">&gt;</span><span class="p">()</span>
<span class="n">promise</span><span class="o">.</span><span class="n">whenSuccess</span> <span class="p">{</span> <span class="nf">print</span><span class="p">(</span><span class="nv">$0</span><span class="p">)</span> <span class="p">}</span>
<span class="n">actor</span><span class="o">.</span><span class="nf">offer</span><span class="p">(</span><span class="o">.</span><span class="nf">getCounter</span><span class="p">(</span><span class="n">promise</span><span class="p">))</span>
<span class="n">actor</span><span class="o">.</span><span class="nf">close</span><span class="p">()</span>
</code></pre>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">@inlinable</span>
<span class="kd">public</span> <span class="kd">func</span> <span class="n">actor</span><span class="o">&lt;</span><span class="kt">T</span><span class="o">&gt;</span><span class="p">(</span><span class="n">of</span> <span class="nv">type</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">,</span>
                     <span class="nv">bufferType</span><span class="p">:</span> <span class="kt"><a href="../Classes/CoChannel.html">CoChannel</a></span><span class="o">&lt;</span><span class="kt">T</span><span class="o">&gt;.</span><span class="kt">BufferType</span> <span class="o">=</span> <span class="o">.</span><span class="n">unlimited</span><span class="p">,</span>
                     <span class="nv">body</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt"><a href="../Classes/CoChannel.html">CoChannel</a></span><span class="o">&lt;</span><span class="kt">T</span><span class="o">&gt;.</span><span class="kt">Receiver</span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt">Void</span><span class="p">)</span>
    <span class="o">-&gt;</span> <span class="kt"><a href="../Classes/CoChannel.html">CoChannel</a></span><span class="o">&lt;</span><span class="kt">T</span><span class="o">&gt;.</span><span class="kt">Sender</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>type</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p><code><a href="../Classes/CoChannel.html">CoChannel</a></code> generic type.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>bufferType</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The type of channel buffer.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>body</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The closure that will be executed inside coroutine.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p><code><a href="../Classes/CoChannel/Sender.html">CoChannel.Sender</a></code> for sending messages to an actor.</p>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
          </section>
        </section>
        <section id="footer">
          <p>&copy; 2020 <a class="link" href="https://github.com/belozierov/SwiftCoroutine" target="_blank" rel="external">Alex Belozierov</a>. All rights reserved. (Last updated: 2020-07-11)</p>
          <p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.13.5</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
        </section>
      </article>
    </div>
  </body>
</div>
</html>
